#pragma once
#include "BasicGameState.h"

namespace ds {

class MenuGameState : public ds::BasicGameState {

struct MenuLink {
	Vec2 pos;
	Vec2 extent;
	std::string text;
	int id;
	bool active;
};

typedef std::vector<MenuLink> MenuLinks;

public:
	MenuGameState(const std::string& stateName,const std::string& materialName,const std::string& layerName) 
		: BasicGameState(stateName,materialName,layerName) 
		, m_SelectedID(-1) 
		, m_Offset(ds::Vec2(0,0)) {}
	virtual ~MenuGameState() {}
	void addLink(int id,const std::string& textNodeName,int x,int y,int width,int height,const std::string& txt,const Color& color = Color(1.0f,1.0f,1.0f,1.0f));
	void setLinkColor(int id,const std::string& textNodeName,const Color& color);
	void setLinkState(int id,const std::string& textNodeName,bool state);
	virtual void onMouseOver(int id) {}
	virtual void onMouseOut(int id) {}
	virtual void onClicked(int id) {}
	bool update(float elapsedTime);
	void OnButtonDown( int button ) {
		m_Pressed = true;
	}
	void OnButtonUp( int button );
	void setMouseOffset(int x,int y) {
		m_Offset = Vec2(x,y);
	}
private:
	bool isInside(const Vec2& mousePos,MenuLink* menuLink) const;
	MenuLinks m_Links;
	int m_SelectedID;
	Vec2 m_Offset;
	bool m_Pressed;
};

}
